
TRIGGER PROCEDURE FOR WRITE OF USR_MSTR OLD BUFFER OLD_USR_MSTR.


{mfdeclre.i }
define new shared work-table wf_old_usr_mstr like usr_mstr.

HK:
do:
    if can-find(first dt_mstr where dt_table = "usr_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "MOD", input recid(usr_mstr), input "usr_mstr").

    if not can-find ( first dt_mstr where dt_table = "usr_mstr" and dt_type = "MOD" ) then leave HK.
    
    if not can-find ( first wf_old_usr_mstr ) then do:
        create wf_old_usr_mstr.
        if recid(wf_old_usr_mstr)= -1 then .
    end.
    
    buffer-copy old_usr_mstr to wf_old_usr_mstr no-error.

    for each dt_mstr no-lock where dt_table = "usr_mstr" and dt_type = "MOD" :
    
        case dt_field :

            when "usr_userid" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_userid, input usr_mstr.usr_userid,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_lang" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_lang, input usr_mstr.usr_lang,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_user1" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_user1, input usr_mstr.usr_user1,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_user2" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_user2, input usr_mstr.usr_user2,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_site" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_site, input usr_mstr.usr_site,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_groups" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_groups, input usr_mstr.usr_groups,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_passwd" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_passwd, input usr_mstr.usr_passwd,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_name" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_name, input usr_mstr.usr_name,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_last_date" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr_last_date), input string(usr_mstr.usr_last_date),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qad01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qad01, input usr_mstr.usr__qad01,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qad02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qad02, input usr_mstr.usr__qad02,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_restrict" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr_restrict), input string(usr_mstr.usr_restrict),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadc03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qadc03, input usr_mstr.usr__qadc03,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadl03" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr__qadl03), input string(usr_mstr.usr__qadl03),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_addr" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_addr, input usr_mstr.usr_addr,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadc02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qadc02, input usr_mstr.usr__qadc02,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadi02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr__qadi02), input string(usr_mstr.usr__qadi02),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadc01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qadc01, input usr_mstr.usr__qadc01,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadl01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr__qadl01), input string(usr_mstr.usr__qadl01),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadl02" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr__qadl02), input string(usr_mstr.usr__qadl02),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadi01" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input string(wf_old_usr_mstr.usr__qadi01), input string(usr_mstr.usr__qadi01),
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr__qadc04" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr__qadc04, input usr_mstr.usr__qadc04,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_mail_address" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_mail_address, input usr_mstr.usr_mail_address,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_type, input usr_mstr.usr_type,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_timezone" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_timezone, input usr_mstr.usr_timezone,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_access_type" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_access_type, input usr_mstr.usr_access_type,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_access_loc" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_access_loc, input usr_mstr.usr_access_loc,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_ctry_code" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_ctry_code, input usr_mstr.usr_ctry_code,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

            when "usr_variant_code" then
                run CreateDthist(input dt_table, input dt_field, input dt_type, input wf_old_usr_mstr.usr_variant_code, input usr_mstr.usr_variant_code,
                    input recid(usr_mstr), input usr_mstr.usr_userid, input "", input "", input "",
                    input "", input "", input "", input "").

        end.

    end.
end.

{hkdttrans.i}
